#include "main.h"

int main(){

    //创立连接
    int socketFD;
    socket_link(&socketFD, "192.168.40.128", "8080");


    //登录和注册
    judge_login(socketFD);

    while(1){
        client_t *cl;
        recv(socketFD, cl, sizeof(cl), MSG_WAITALL);
        printf("%s:%s$ ", cl->name, cl->dir_path);
        fflush(stdout);
        
        char buf[120] = { 0 };
        int ret = read(STDIN_FILENO, buf, sizeof(buf));
        ERROR_CHECK(ret, -1, "read_main.c");

        sendc_t sc;
        bzero(&sc, sizeof(sc));
        sc = slice_command(buf);
        ret = send(socketFD, &sc, sizeof(sc), MSG_NOSIGNAL);
        ERROR_CHECK(ret, -1, "send_main");

        //接收服务端发送来的信息
        recv_msg(socketFD, sc.num);
        

    }



    return 0;
}

